Skip to content

Conversation

@dmpots
Copy link
Collaborator

@dmpots dmpots commented Oct 8, 2025

This commit modifies the way we represent threads in the AMDGPU plugin. Previously, we would represent each GPU wave as a thread, which matches the way it is done in rocgdb.

Now, we represent each GPU lane as a thread, which is the design choice we made for lldb. The benefit of lanes-as-threads is to make the debugger representation match the programming model more closely. This is also the way the Nvidia plugin represents threads.

As part of this change we add a new WaveAMDGPU class that represents a GPU wave. Each thread maintains a pointer to the wave it belongs to. This allows us to store common wave information in the wave object, and access it from any thread in the wave.

We use a map to hold the currently active waves, which we retrieve from the dbgapi. This map is updated when a new wave is created, and when a wave is destroyed.

The core of the logic is driven from the UpdateThreads function, which can be called by lldb-server or directly from the plugin. We call update threads when we receive a wave-stop event to refresh the thread list.

To update the thread list we query the dbgapi for the currently active waves, and add any new waves to the map. We then iterate over the list of active waves and refresh the wave info for that wave. Finally, for any new waves we add the threads in the wave to the thread list and remove any threads that are now dead. We avoid rebuilding the thread list each time we update the waves because we want to keep the order of threads deterministic in the list and the dbgapi does not guarantee a consistent order when querying the active waves.

This commit modifies the way we represent threads in the AMDGPU plugin.
Previously, we would represent each GPU *wave* as a thread, which matches
the way it is done in rocgdb.

Now, we represent each GPU *lane* as a thread, which is the design choice we made
for lldb. The benefit of lanes-as-threads is to make the debugger representation
match the programming model more closely. This is also the way the Nvidia
plugin represents threads.

As part of this change we add a new `WaveAMDGPU` class that represents a GPU wave.
Each thread maintains a pointer to the wave it belongs to. This allows us to store
common wave information in the wave object, and access it from any thread in the
wave.

We use a map to hold the currently active waves, which we retrieve from the dbgapi.
This map is updated when a new wave is created, and when a wave is destroyed.

The core of the logic is driven from the `UpdateThreads` function, which can be called
by lldb-server or directly from the plugin. We call update threads when we receive a
wave-stop event to refresh the thread list.

To update the thread list we query the dbgapi for the currently active waves,
and add any new waves to the map. We then iterate over the list of active waves
and refresh the wave info for that wave. Finally, for any new waves we add the
threads in the wave to the thread list and remove any threads that are now dead.
We avoid rebuilding the thread list each time we update the waves because we
want to keep the order of threads deterministic in the list and the dbgapi does
not guarantee a consistent order when querying the active waves.
@dmpots dmpots merged commit 2f8bf80 into clayborg:llvm-server-plugins Oct 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants